﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Insert</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <script src="~/Source/Editor/utf8-asp/ueditor.config.js"></script>
    <script src="~/Source/Editor/utf8-asp/ueditor.all.min.js"></script>
    <script src="~/Source/Editor/utf8-asp/lang/zh-cn/zh-cn.js"></script>

    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>

    <script>
        $(function () {

            //实例化编辑器
            //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
            var ue = UE.getEditor('editor');


            $("#btnSave").click(function() {
                $.post("/Notice/InsertNotice", { "Title": $("#Title").val().trim(), "Content": ue.getContent() }, function (returnData) {
                    if (returnData) {
                        alert("发布成功！！！");
                        setInterval(function () {
                            window.location.reload();
                        }, 1500);
                    } else {
                        alert("发布失败！！！");
                    }
                });
            });

        })
    </script>
</head>
<body>
    <form class="am-form" id="NoticFrm">
        <div class="am-g am-margin-top">
            <div class="am-u-sm-2 am-text-right">
                文章标题
            </div>
            <div class="am-u-sm-4">
                <input type="text" id="Title" class="am-input-sm">
            </div>
            <div class="am-u-sm-6"></div>
        </div>
        <br />
        <div class="am-g am-margin-top-sm">
            <div class="am-u-sm-2 am-text-right">
                内容描述
            </div>
            <div class="am-u-sm-10">
                <script id="editor" type="text/plain" style="width: 1024px; height: 500px;"></script>
            </div>
        </div>
        <br />
        <div class="am-margin">
            <button type="button" class="am-btn am-btn-primary am-btn-xs" id="btnSave">提交保存</button>
            <button type="reset" class="am-btn am-btn-primary am-btn-xs">放弃保存</button>
        </div>
    </form>
</body>
</html>
